package com.tidc.seaquartz.job;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tidc.seaquartz.util.RabbitUtil;
import com.tidc.seaservermapper.dao.RabbitMessageLogDao;
import com.tidc.seaservermodel.config.RabbitConfig;
import com.tidc.seaservermodel.entity.RabbitMessageLog;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.scheduling.quartz.QuartzJobBean;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author ：冯涛滔
 * @date ：Created in 2020/10/23 21:23
 * @description：
 * @modified By：
 * @version:
 */
@Slf4j
public class ClearRabbit extends QuartzJobBean {
    @Resource
    private RabbitMessageLogDao rabbitMessageLogDao;
    @Resource
    private RabbitUtil rabbitUtil;
    @Resource
    private ObjectMapper objectMapper;
    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("检查未发送消息");
        RabbitMessageLog rabbitMessageLog = RabbitMessageLog.checkClearRabbit("");
        rabbitMessageLogDao.insert(rabbitMessageLog);
        rabbitUtil.sendMQ(rabbitMessageLog);
    }
}
